|
|
|
|
|
|
|
Also, every time a new entry is added, a single new node must be added by using the same key logic (discussed in a later section). Now, add a few records to the database by using the Visual Data Manager, and then run the application to see how TreeView processing works. In the example in Figure 10.13, the TreeView control automatically provides a plus sign (+) to note which main letter nodes contain data entries. |
|
|
|
|
|
|
|
|
The data displayed in the ListView control will change whenever users select a different letter in the TreeView control, much the same way as Windows Explorer displays the contents of a directory that was selected. To do this, you need to know when a new letter was selected in the TreeView and then clear the ListView to reinitialize it. The first step in the process is to recognize when a node is selected; the second is to know if the selected node is a letter or a name. The NodeClick event routine is triggered whenever a node is selected in the TreeView control. The code in Listing 10.10 checks to see if the node was a letter or a name, and then calls the appropriate routines, passing the selected letter as an argument. |
|
|
|
|
|
|
|
|
LISTING 10.10. ADDRDAO3.TXTCHECKING FOR A LETTER NODE TO CALL THE LISTVIEW INITIALIZATION ROUTINE. |
|
|
|
 |
|
|
|
|
1: Private Sub tvTreeView_NodeClick(ByVal Node As ComctlLib.Node)
2: If Len(Node.Key) = 1 Then
3: Call Set_ListView(Node.Key)
4: Else
5: If InStr(1, tvTreeView.SelectedItem.Key, !) > 0 Then
6: frmAddressEntry.sqlEntry = select * from [Address Entry] _ Where _
7: [AddressID] = & Mid(tvTreeView.SelectedItem.Key, 1, _
8: InStr(1, tvTreeView.SelectedItem.Key, !) - 1)
9: End If
10: End If
11: End Sub |
|
|
|
|
|
|
|
|
The ListView initialization routine takes the letter passed to it and open a dynaset by using the following SQL to retrieve the entries that start with that letter: |
|
|
|
|
|
|
|
|
SELECT * FROM [Address Entry] WHERE [LastName] Like M* |
|
|
|
|
|
|
|
|
Then, by using a loop, it adds each record to the ListView as shown in Listing 10.11. |
|
|
|
|
|